package bean;

import java.util.List;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import dao.NoticiaDAO;

import model.Noticia;

/**
 * Session Bean implementation class NoticiaEJB
 */
@Stateless
@LocalBean
public class NoticiaEJB implements NoticiaEJBLocal {

	@PersistenceContext(unitName="galeradoconcurso")
	private EntityManager em;
	
    public NoticiaEJB() {
        // TODO Auto-generated constructor stub
    }

	@Override
	public void cadastrarNoticia(Noticia n) {
		NoticiaDAO noticiadao = new NoticiaDAO(em);
		noticiadao.adicionar(n);		
	}

	@Override
	public void removerNoticia(Noticia n) {
		NoticiaDAO noticiadao = new NoticiaDAO(em);
		noticiadao.remove(n);
	}

	@Override
	public List<Noticia> listarNoticia() {
		NoticiaDAO noticiadao = new NoticiaDAO(em);
		return noticiadao.listar();
	}

}
